/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package transaction.approval.exam_approval;

import common.util.HibernateUtil;
import java.awt.HeadlessException;
import javax.swing.JOptionPane;
import org.hibernate.Session;
import org.hibernate.Transaction;
import system.SystemMassages;
import template.DefaultRegistrationForm;
import template.RegistrantionPanel;

/**
 *
 * @author Banuka
 */
public class REGExamApproval extends DefaultRegistrationForm{

    @Override
    public RegistrantionPanel objectCreator() {
        examApproval = new PCExamApproval();
        return examApproval;
    }

    @Override
    public Object initObject(RegistrantionPanel pnl) {
       return pnl.initObject();
    }

    @Override
    protected String setFrameTitle() {
        return TITLE;
    }

    @Override
    protected void getAutoFillComponents(RegistrantionPanel pnl) {
    }

    @Override
    protected String getViewDataList() {
        return "from transaction.approval.exam_approval.object.TCustomerExam";
    }

    @Override
    protected void save() {
        Object[] examApprovalList = examApproval.initObjectList();
        Session session = HibernateUtil.getSession();
        Transaction transaction = session.beginTransaction();
        try {
            for (Object object : examApprovalList) {
                session.save(object);
            }
            transaction.commit();
            JOptionPane.showMessageDialog(null, SystemMassages.SAVED_SUCCESS);
        } catch (HeadlessException e) {
            
        }
    }
    
    private PCExamApproval examApproval;
    private static final String TITLE = "Exam Approval";
}
